#include "Game.h"
#include "XMLParser.h"



using namespace std;




/**
 * Loads all Monster information for the game.
 * @see GetConfig::GetConfig()
 * @see GetConfig::addATTROption()
 * @see GetConfig::readClassConfigFile
 * @param void
 * @return void
 */
void Game::loadMonstersInformation()
{
	XMLParser appConfig(GAME_LOADCONFIG_MONSTER_ROOTELEM, GAME_LOADCONFIG_MONSTER_FIRSTELEM);

	appConfig.addATTROption(GAME_LOADCONFIG_MONSTER_ATTR1);
	appConfig.addATTROption(GAME_LOADCONFIG_MONSTER_ATTR2);
	appConfig.addATTROption(GAME_LOADCONFIG_MONSTER_ATTR3);
	appConfig.addATTROption(GAME_LOADCONFIG_MONSTER_ATTR4);
	appConfig.addATTROption(GAME_LOADCONFIG_MONSTER_ATTR5);
	appConfig.addATTROption(GAME_LOADCONFIG_MONSTER_ATTR6);
	appConfig.addATTROption(GAME_LOADCONFIG_MONSTER_ATTR7);
	appConfig.addATTROption(GAME_LOADCONFIG_MONSTER_ATTR8);
	appConfig.addATTROption(GAME_LOADCONFIG_MONSTER_ATTR9);
	appConfig.addATTROption(GAME_LOADCONFIG_MONSTER_ATTR10);
	appConfig.addATTROption(GAME_LOADCONFIG_MONSTER_ATTR11);
	appConfig.readMonsterConfigFile(GAME_LOADCONFIG_MONSTER_FILENAME, m_monsters);
}


/**
 * Prints out information about all the Monster in the Game
 * @param void
 * @return void
 */
void Game::showMonstersInformation()
{
	if (m_monsters.size() == 0)
	{
		cout << "No monsters information available." << endl;
	}
	else
	{
		cout << "==================" << endl;
		for (unsigned int i = 0; i < m_monsters.size(); ++i)
		{
			m_monsters[i]->print();
			m_monsters[i]->printSpecific();
		}
		cout << "==================" << endl;
	}
}


/**
 * Deletes all Monsters in the Game
 * @param void
 * @return void
 */
void Game::freeMonstersInformation()
{
	if (m_monsters.size() == 0)
	{
		cout << "No monster information available." << endl;
	}
	else
	{
		for (unsigned int i = 0; i < m_monsters.size(); ++i)
		{
			Monster* monster;

			monster = m_monsters[i];
			delete monster;
		}
		m_monsters.resize(0);
	}
}